<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=trim($_RQ['ordersn']);
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
	if(!empty($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
    $fields=array('id','ordersn','name','mobile','driver_id','mid','createtime','status','price','start_seat','dest_seat');
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_daijia_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);	
	foreach($return['list'] as &$v){
		
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'name','title'=>'联系人','type'=>'string'),
			array('name'=>'mobile','title'=>'电话','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),	
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
						
		),
		'action'=>array(	
			array('type'=>'href','op'=>'detail','title'=>'详细'),
			
		),),
		
		'search'=>array(
			array('name'=>'ordersn','width'=>15,'title'=>'订单号','type'=>'string'),
			array('name'=>'name','width'=>15,'title'=>'联系人','type'=>'string'),
			array('name'=>'status','width'=>15,'title'=>'订单状态','type'=>'radio','options'=>'status'),
		)
	);
	$return['status']=$this->order_status;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_daijia_order',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_daijia_order',array('id'=>$id));	
			}
		}
	}
	exi('删除成功！');

}
if($_RQ['op']=='detail'){

	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择订单','error','list');
	}
	
	$return['item']=pdo_get('jy_daijia_order',array('id'=>$id));
	$return['item']['createtime']=date('Y-m-d H:i:s',$return['item']['createtime']);
	///print_r($return['item']);exit();
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'订单详情',		
		'edit'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string','read'=>true),
			array('name'=>'name','title'=>'联系人','type'=>'string','read'=>true),
			array('name'=>'mobile','title'=>'电话','type'=>'string','read'=>true),
			array('name'=>'price','title'=>'总金额','type'=>'string','read'=>true),
			array('name'=>'price1','title'=>'接客费用','type'=>'string','read'=>true),
			array('name'=>'price2','title'=>'打车费用','type'=>'string','read'=>true),
			array('name'=>'start_seat','title'=>'出发地','type'=>'string','read'=>true),
			array('name'=>'dest_seat','title'=>'目的地','type'=>'string','read'=>true),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status','read'=>true),	
			array('name'=>'createtime','title'=>'下单时间','type'=>'string','read'=>true),
			
		)
		);
	$return['htmls']=$htmls;
	$return['status']=array('0'=>'下单','1'=>'接单','2'=>'申请取消','3'=>'已取消','4'=>'已退款','5'=>'已完成');
	
	exi($return);
}
?>